package com.nms.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * 封装新闻的类
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name="t_news")
public class News {

	/** 编号 */
	private String id;
	/** 主标题 */
	private String mainTitle;
	/** 副标题 */
	private String subTitle;
	/** 辅助标题 */
	private String assistTitle;
	/** 导语 */
	private String introduction;
	/** 主体*/
	private String content;
	/** 背景*/
	private String background;
	/** 结语*/
	private String conclusion;
	
	/** 来源*/
	private String origin;
	/** 紧急程度 */
	private Integer degree;
	/** 类型id:13：文本，12：图片，11视频。 */
	private NewsType type;
	/** 类型id：1：国内，2：国际 */
	private NewsType type2;
	/** 类型 id：*/
	private NewsType type3;
	/** 0：表示不是头条，1：表示头条*/
	private Integer topLine;
	/** 发布时间 */
	private Date releaseTime;
	/** 生命周期（时间） */
	private Date activeTime;
	/** 评论数*/
	private Integer commentCount;
	/** 关注度*/
	private Integer concernCount;
	/** 转播数*/
	private Integer rebroadcast;
	private String keyword;
	private User publisher;
	private Set<Comment> comments;
	
	/**
	 * 获得新闻的编号（id）
	 * @return
	 */
	@Id
	@Column(name="id",length=64)
	@GeneratedValue(generator="uuid")
	@GenericGenerator(name="uuid",strategy="uuid")
	public String getId() {
		return id;
	}
	
	/**
	 * 设置新闻的编号（id）
	 * @param id
	 */
	public void setId(String id) {
		this.id = id;
	}

	@Column(name="content")
	public String getContent() {
		return content;
	}

	/**
	 * 设置新闻的内容
	 * @param content
	 */
	public void setContent(String content) {
		this.content = content;
	}
	
	/**
	 * 获得新闻的类型
	 * @return
	 */
	@OneToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="type",referencedColumnName="id")
	public NewsType getType() {
		return type;
	}
	
	/**
	 * 设置新闻的类型
	 * @param type
	 */
	public void setType(NewsType type) {
		this.type = type;
	}
	
	@OneToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="type2",referencedColumnName="id")
	public NewsType getType2() {
		return type2;
	}

	public void setType2(NewsType type2) {
		this.type2 = type2;
	}
	
	@OneToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="type3",referencedColumnName="id")
	public NewsType getType3() {
		return type3;
	}

	public void setType3(NewsType type3) {
		this.type3 = type3;
	}

	@Column(name="top_line")
	public Integer getTopLine() {
		return topLine;
	}

	public void setTopLine(Integer topLine) {
		this.topLine = topLine;
	}

	@Column(name="main_title")
	public String getMainTitle() {
		return mainTitle;
	}

	public void setMainTitle(String mainTitle) {
		this.mainTitle = mainTitle;
	}

	@Column(name="sub_title")
	public String getSubTitle() {
		return subTitle;
	}

	public void setSubTitle(String subTitle) {
		this.subTitle = subTitle;
	}

	@Column(name="assist_title")
	public String getAssistTitle() {
		return assistTitle;
	}

	public void setAssistTitle(String assistTitle) {
		this.assistTitle = assistTitle;
	}

	@Column(name="introduction")
	public String getIntroduction() {
		return introduction;
	}

	public void setIntroduction(String introduction) {
		this.introduction = introduction;
	}

	@Column(name="background")
	public String getBackground() {
		return background;
	}

	public void setBackground(String background) {
		this.background = background;
	}

	@Column(name="conclusion")
	public String getConclusion() {
		return conclusion;
	}

	public void setConclusion(String conclusion) {
		this.conclusion = conclusion;
	}

	@Column(name="origin")
	public String getOrigin() {
		return origin;
	}

	public void setOrigin(String origin) {
		this.origin = origin;
	}

	@Column(name="degree")
	public Integer getDegree() {
		return degree;
	}

	public void setDegree(Integer degree) {
		this.degree = degree;
	}

	@Column(name="release_time")
	public Date getReleaseTime() {
		return releaseTime;
	}

	public void setReleaseTime(Date releaseTime) {
		this.releaseTime = releaseTime;
	}

	@Column(name="active_time")
	public Date getActiveTime() {
		return activeTime;
	}

	public void setActiveTime(Date activeTime) {
		this.activeTime = activeTime;
	}

	@Column(name="comment_count")
	public Integer getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(Integer commentCount) {
		this.commentCount = commentCount;
	}

	@Column(name="concern_count")
	public Integer getConcernCount() {
		return concernCount;
	}

	public void setConcernCount(Integer concernCount) {
		this.concernCount = concernCount;
	}

	@Column(name="rebroadcast")
	public Integer getRebroadcast() {
		return rebroadcast;
	}

	public void setRebroadcast(Integer rebroadcast) {
		this.rebroadcast = rebroadcast;
	}

	@Column(name="keyword")
	public String getKeyword() {
		return keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	@OneToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="publisher_id", referencedColumnName="id")
	public User getPublisher() {
		return publisher;
	}

	public void setPublisher(User publisher) {
		this.publisher = publisher;
	}

	@OneToMany(targetEntity=Comment.class, mappedBy="news",fetch=FetchType.EAGER)
	public Set<Comment> getComments() {
		return comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}
}
